/**
 * 
 */
package com.edocbase.desktop.plugins.mdiary;

import java.util.HashMap;
import java.util.Map;

import com.edocbase.desktop.lightweight.DesktopTabGroup;
import com.edocbase.desktop.lightweight.widgets.RibbonButton;
import com.edocbase.desktop.lightweight.widgets.SplitButton;

/**
 * @author X61
 *
 */
public class ToolButtonManager {
	private MDiaryUI diaryUI = null;
	private Map<String,ButtonComposite> btnCache = new HashMap<String, ButtonComposite>();
	private Map<String,DesktopTabGroup> grpCache = new HashMap<String, DesktopTabGroup>();
	public ToolButtonManager(MDiaryUI mDiaryUI) {
		this.diaryUI = mDiaryUI;
	}
	public void add(String id,SplitButton nsButton) {
		btnCache.put(id, new ButtonComposite(id,nsButton));
	}
	public void add(String id, RibbonButton newButton) {
		if (newButton.getActionId()==null){
			newButton.setActionId(id);
		}
		btnCache.put(id, new ButtonComposite(id,newButton));
	}

	public ButtonComposite[] getButtons(String... ids){
		ButtonComposite[] buttons = new ButtonComposite[ids.length];
		for (int i=0;i<ids.length;i++){
			String id = ids[i];
			if (btnCache.containsKey(id)){
				buttons[i] = btnCache.get(id);
			}
		}
		return buttons;
	}
	public ButtonComposite getButton(String id){
		ButtonComposite btn = null;
		if (btnCache.containsKey(id)){
			btn = btnCache.get(id);
		}
		return btn;
	}
	public void addGroup(String id, DesktopTabGroup grp) {
		grpCache.put(id, grp);
	}
	public DesktopTabGroup getGroup(String id){
		return grpCache.get(id);
	}
}
